package com.ityj.yygh.hospital.controller;

import com.ityj.yygh.hospital.service.HospitalService;
import com.ityj.yygh.model.hosp.Hospital;
import com.ityj.yygh.result.Result;
import com.ityj.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(value = "医院信息")
@RestController
@RequestMapping(path = "/admin/hosp/hospital")
@Slf4j
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @ApiOperation(value = "获取所有的医院配置")
    @GetMapping(path = "/list/{pageNum}/{pageSize}")
    public Result<Object> listHospitalInfo(@PathVariable Integer pageNum, @PathVariable Integer pageSize, HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> hospitalPage = hospitalService.searchHopitalInfoByCondition(hospitalQueryVo, pageNum, pageSize);
        return Result.ok(hospitalPage);
    }

    @ApiOperation(value = "更新医院的状态")
    @GetMapping(path = "/updateHospitalStatus/{id}/{status}")
    public Result<Object> updateHospitalStatus(@PathVariable String id, @PathVariable Integer status) {
        hospitalService.updateHospitalStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "获取医院的详细配置")
    @GetMapping(path = "/hospdetail/{id}")
    public Result<Map<String, Object>> findHospDetailById(@PathVariable String id) {
        Map<String, Object> result = hospitalService.findHospDetailById(id);
        return Result.ok(result);
    }

}
